<template >
	<div  >

		<flexbox orient="vertical" class="pl10 pr10">

	      <flexbox-item class="text-center">
	      	<img class="mt50" src="../../assets/qmlogo.png" width="50" height="50">
	      </flexbox-item>

	      <flexbox-item class="text-center h2">
	      	{{information}}
	      </flexbox-item>

	      <flexbox-item class="text-center h4">
	      	支付金额：<span class="h2 red">¥ {{pay_fee}}</span>
	      </flexbox-item>

	      <flexbox-item>
	      	<yd-button size="large" type="primary" @click.native="orderinfo">查看订单</yd-button>
	      </flexbox-item>

	      <flexbox-item class="pl10">
	      	<div class=" mt20 h4">群盟提示：</div>
			<div class=" mt10 h4">1.在海报进入的产品详情页面左下角可以查看订单</div>
			<div class=" mt10 h4">2.关注 {{configureinfo.company_name}} 公众号,方便查看订单</div>
	      </flexbox-item>

	      <flexbox-item class="text-center">
	      	<img class="mt50" :src="configureinfo.qrcodeimg" width="200" height="200">
	      </flexbox-item>

	    </flexbox>
	</div>
</template>


<script >

import { mapGetters } from 'vuex';


export default {

	name : 'makeorder',

	data () {
		return {
			
			information : '收款中',
			pay_fee : '收款中',
		}
	},

	computed : {
		...mapGetters([
			'configureinfo',
			'company_code',
			'URL',
		]),

		ordercode () {
			return this.$route.query.code;
		}
	},

	components : {
		
	},

	methods : {
		_getPaystate () {
			console.log(this.ordercode);
			var time1 = setInterval(() => {
				this.$store.dispatch('orderInfo', {
					code : this.ordercode,
					callback : (orderinfo) => {
						if(orderinfo.pay_state == '1'){
							this.information = '支付成功';
							this.pay_fee = orderinfo.pay_fee;
							clearInterval(time1);

let url1 = this.URL.shop + 'orderinfo/' + this.ordercode + '?company_code=' + this.company_code;

window.location.href = this.URL.api + 'v1/pn/ordermsg?'+
'company_code=' + this.company_code + 
'&rurl='+ encodeURIComponent(url1) +
'&code=' + this.ordercode;

						}
					}
				});
			}, 1000);
		},

		orderinfo () {
			console.log('orderinfo');
			console.log(this.ordercode);
			this.$router.push({ 
				'name': 'orderinfo', 
				'params': { code: this.ordercode },
				'query' : { 
					'company_code' : this.company_code,
				}
			});
		}
		
	},

	created () {
		this._getPaystate();
		this.$store.dispatch('getConfigureinfo', {
			'company_code' : this.company_code,
			'callback' : () => {

			}
		});
	},
	
}
	

</script>

<style scope>

body {
	background-color: #fff;
}
</style>